package jin.si.com.web;

import jin.si.com.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: freemarker页面测试
 * @ClassName TestFreeMarker
 * @Author MT
 * @Date 2021/5/12 14:40
 **/

@Controller
@RequestMapping("/free")
public class TestFreeMarker {

    @RequestMapping("/getFree")
    public String getFree(ModelMap model){
        User user=new User();
        user.setName("大橙子");
        model.addAttribute("user",user);
        model.addAttribute("name","臭宝宝");
        model.addAttribute("age",25);

        //=============================
        List<User> list=new ArrayList<>();

        User u1=new User();
        u1.setName("猪肉");
        User u2=new User();
        u2.setName("粉条");
        User u3=new User();
        u3.setName("馒头");

        list.add(u1);
        list.add(u2);
        list.add(u3);
        model.addAttribute("list",list);
        return "/freemarker/index";
    }


}
